﻿using System;
using System.Collections.Generic;
using System.Data;
using Ue.Framework.Data;
using Ue.Infrastructure.EntityFactoryFramework;
using Ue.Qcdz.Domain.TreeViews;

namespace Ue.Qcdz.Repositories.TreeViews
{
    public class TreeViewFactory : IEntityFactory<TreeView>
    {
        internal const string TableName = "TreeViews";

        internal class FieldNames : FieldNamesBase
        {
            public const string Name = "Name";
            public const string Description = "Description";
        }

        public TreeView BuildEntity(IDataReader reader)
        {
            TreeViewProxy treeView = new TreeViewProxy(
                reader.Get<Guid>(FieldNames.EntityKey),
                reader.Get<DateTime>(FieldNames.CreateOn));

            treeView.Name = reader.Get<string>(FieldNames.Name);
            treeView.Description = reader.Get<string>(FieldNames.Description);

            return treeView;
        }
    }
}
